<?php
namespace app\admin\controller;

use app\common\controller\Common;
use think\Loader;
use think\captcha\Captcha;

class Login extends Common
{
    
    public function index()
    {
        return $this->fetch();
    }

    public function checklogin()
    {
    	$data = input('post.');

    	 //  // 2 验证数据 
        $validate = Loader::validate('Login');

        if(!$validate->check($data)){
            $this->error($validate->getError());
        }else{
            $this->success("登录成功");
        }
    }

    public function code()
    {
    	$config =    [
		    // 验证码字体大小
		    'fontSize'    =>    30,    
		    // 验证码位数
		    'length'      =>   3,   
		    // 关闭验证码杂点
		    'useNoise'    =>    false, 
 		];
    	$captcha = new Captcha($config);
		return $captcha->entry();
    }
}
